using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace TextEditor
{
    public class HashTableVariableProvider : IVariableProvider
    {
        private Hashtable myValues;

        public HashTableVariableProvider()
        {
            this.myValues = null;
            this.myValues = new Hashtable();
        }

        public HashTableVariableProvider(Hashtable vars)
        {
            this.myValues = null;
            this.myValues = vars;
        }

        public bool Exists(string Name)
        {
            return this.myValues.ContainsKey(Name);
        }

        public string Get(string Name)
        {
            return Convert.ToString(this.myValues[Name]);
        }

        public void Set(string Name, string Value)
        {
            this.myValues[Name] = Value;
        }

        public string[] AllNames
        {
            get
            {
                ArrayList list = new ArrayList();
                foreach (object k in this.myValues.Keys)
                {
                    list.Add(Convert.ToString(k));
                }
                return (string[])list.ToArray(typeof(string));
            }
        }

        public Hashtable Values
        {
            get
            {
                return this.myValues;
            }
        }
    }
}
